<%+header%>
<style type="text/css">
.linktype{color:#0069d6; text-decoration:none;}
.linktype:visited{color:#0069d6; text-decoration:none;}
.linktype:hover{color:#0069d6; text-decoration:none;}
.title2{font-size:20px;}
</style>
<script>  //general function
	function getValue(ID)
	{
		return document.getElementById(ID).value;
	}
	function setValue(ID,val){
		document.getElementById(ID).value=val;	
	}
	function setDisplay(ID,type)
	{
		if(!type)
		{
			document.getElementById(ID).style.display="none";
		}
		else
		{
			document.getElementById(ID).style.display="inline";
		}
	}
	function setHTML(ID,STR)
	{
		document.getElementById(ID).innerHTML=STR;
	}
	
</script>
<script>//init	
	var buttonStart="<%:start%>";
	var buttonStop="<%:stop%>";
	function ConfigScan(val){
		 if(buttonStart == val){
		     val="start";	
		 }else if(buttonStop == val){
		     val="stop";	
		 }
		 
		 var callPath='<%=luci.dispatcher.build_url("admin", "wifiscan","ConfigScan")%>';
       callPath=callPath+'/'+val;
	   XHR.get(callPath,null,function(x,rval){
	   	
	   	       switch(rval[0])
	   	       { 
	   	       	   case "runing":
	   	           case "stop":
	   	               setValue("ID_INPUT_ConScan",buttonStop);
	   	           break;	
	   	           case "unruning":
	   	           case "start":
	   	               setValue("ID_INPUT_ConScan",buttonStart);
	   	           break;
	   	           default:
	   	               alert("lua action is err!");
	   	           break;
	   	       }
		         
		     }
	   );
	}
	ConfigScan("status");	
</script>
<script>

function show_Query(ID)
{
    if("ID_TR_AP" == ID)
        _ID = "ID_TR_TM";
    else
        _ID = "ID_TR_AP";

    var sta = document.getElementById(ID).style.display;
    setDisplay(ID,sta == "inline" ? false : true);
    setDisplay(_ID,false);
}

function goto_APdev_info()
{
    var AP_Dev_Url = '<%=luci.dispatcher.build_url("admin/wifiscan/APdeviceinfo")%>';
    var ssid_name = getValue("id_ssid_name");
    var mac = getValue("id_mac");
    var freq = getValue("id_Frequency");
    var sigpath = getValue("id_sigPath");
    var enc = getValue("id_Encryption");

    var param = "?"+ssid_name+"?"+mac+"?"+freq+"?"+sigpath+"?"+enc;
	document.location.assign(AP_Dev_Url + param);
}

function goto_TM_info()
{
    var TM_Url = '<%=luci.dispatcher.build_url("admin/wifiscan/Terminalequipinfo")%>';
    var smac = getValue("id_source_mac");
    var dmac = getValue("id_dest_mac");
    var emac = getValue("id_internet_mac");
    var reqssid = getValue("id_req_con_ssid");

    var param = "?"+smac+"?"+dmac+"?"+emac+"?"+reqssid;
	document.location.assign(TM_Url + param);
}

</script>
<h2><a id="content" name="content"><%:WIFI Scan%></a></h2>

<fieldset>
		<table>
				<tr>
					<td width="20%"><strong><%:Scan configuration:%></strong></td>
					<td width="40%">
						<input id="ID_INPUT_ConScan" type="button" onclick="ConfigScan(this.value)"  class="cbi-button">
					</td>
					<td></td>
				</tr>
				<tr>
					<td colspan = "2">
						<div>
							 <strong><%:Scan the results:%></strong><br><br>
							 	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<a class="linktype"  href="#" onClick="goto_APdev_info()"><%:AP device information......%></a><br><br>
					 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						 		<a class="linktype" href="#" onClick="goto_TM_info()"><%:Terminal equipment information......%></a>
						</div>
					</td>
					
					<td></td>
				</tr>
				<tr>
					<td colspan = "2">
						<div>
							 <strong><%:Scan Query:%></strong><br><br>
							 <table>
                                <tr>
                                    <td>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <a class="linktype"  href="#" onClick="show_Query('ID_TR_AP');" ><%:AP Device Query%></a>
                                    </td>
                                </tr>
                                <tr  id="ID_TR_AP" style="display:none" >
                                    <td>
                                        <table>
                                            <tr>
                                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <%:SSID Name:%>
                                                </td>
                                                <td><input type="text" id="id_ssid_name" /></td>
                                            </tr>
                                            <tr>
                                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <%:MAC%>:
                                                </td>
                                                <td><input type="text" id="id_mac" /></td>
                                            </tr>
                                            <tr>
                                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <%:Frequency%>:
                                                </td>
                                                <td><input type="text" id="id_Frequency" /></td>
                                            </tr>
                                            <tr>
                                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                   <%:Signal Path%>:
                                                </td>
                                                <td><input type="text" id="id_sigPath" /></td>
                                            </tr>
                                            <tr>
                                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <%:Encryption%>:
                                                </td>
                                                <td><input type="text" id="id_Encryption" /></td>
                                            </tr>

                                        </table>
                                        
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <a class="linktype"  href="#" onClick="show_Query('ID_TR_TM');" ><%:Terminal Device Query%></a>
                                    </td>
                                </tr>
                                <tr  id="ID_TR_TM" style="display:none" >
                                    <td>
                                       <table>
                                            <tr>
                                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                   <%:Source MAC%>:
                                                </td>
                                                <td>
                                                    <input type="text" id="id_source_mac" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                   <%:Dest MAC%>:
                                                </td>
                                                <td>
                                                    <input type="text" id="id_dest_mac" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                   <%:Internet MAC%>:
                                                </td>
                                                <td>
                                                    <input type="text" id="id_internet_mac" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                   <%:Request Connection SSID%>:
                                                </td>
                                                <td>
                                                    <input type="text" id="id_req_con_ssid" />
                                                </td>
                                            </tr>
                                        </table>
                                        
                                    </td>
                                </tr>
							 </table>
                           
						</div>
					</td>
					
					<td></td>
				</tr>
		</table>	

		
</fieldset>

<%+footer%>